package yhao.demo.autocode.demo;

import yhao.demo.autocode.core.method.FormFieldInfo;
import yhao.demo.autocode.core.method.FormInfo;
import yhao.demo.autocode.core.method.NewMethodHelper;

import java.io.IOException;

/**
 * 生成新的方法，
 * <p>该生成组件将按照您给定的参数，生成贯穿yhao框架的所有基本结构中所需要的代码。
 *
 * @see NewMethodHelper
 */
public class NewMethodTest {
    public static void main(String[] args) throws IOException {
        newMethod();
    }

    private static void newMethod() throws IOException {
        //无需自定义，直接使用现成的IdsForm
        //FormInfo formInfo = new FormInfo("IdsForm",false);

        //自定义form
        FormInfo formInfo = new FormInfo("NameForm",true);
        formInfo.setExtendsForm("IdForm");
        formInfo.addField(new FormFieldInfo(
                "name","String","名称",true));

        //开始生成
        NewMethodHelper helper = new NewMethodHelper(
                "addName", NewMethodHelper.HttpMethodEnum.POST,
                "/name", "Name",
                formInfo,NewMethodHelper.ReturnTypeEnum.ALONE,
                "新增名称","新增名称传参");
        helper.setRemoteName("cityRemote");
        helper.doNew();
    }
}
